//
//  YQManagerWalletVC.m
//  NewRetail
//
//  Created by yuqin on 2019/6/25.
//  Copyright © 2019 yuqin. All rights reserved.
//

#import "YQManagerWalletVC.h"
#import "YQManagerCell.h"
#import "YQTransferFootView.h"
#import "YQWalletDetailVC.h"
#import "YQImportWalletVC.h"
#import "YQNewWalletAddressVC.h"

@interface YQManagerWalletVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *managerTableView;
@property (nonatomic, strong) YQTransferFootView *footView;

@end

@implementation YQManagerWalletVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.txtTitle.text = @"管理钱包";
    self.view.backgroundColor = UIColorFromRGB(0xeeeeee);
    [self setupTableView];
}

#pragma mark - layout
- (void)setupTableView {
    [self.view addSubview:self.managerTableView];
    [self.managerTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(NavigationStatusBarHeight);
        make.left.mas_equalTo(kMargin_left);
        make.size.mas_equalTo(CGSizeMake(ScreenWidth-2*kMargin_left, ScreenHeight-NavigationStatusBarHeight-Botoom_IPhoneX-50));
    }];
    [self.view addSubview:self.footView];
}

#pragma mark - dy
- (UITableView *)managerTableView {
    if (!_managerTableView) {
        _managerTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _managerTableView.delegate = self;
        _managerTableView.dataSource = self;
        _managerTableView.backgroundColor = [UIColor clearColor];
        _managerTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_managerTableView registerClass:[YQManagerCell class] forCellReuseIdentifier:YQ_ManagerCell];
    }
    return _managerTableView;
}

- (YQTransferFootView *)footView {
    if (!_footView) {
        _footView = [[YQTransferFootView alloc] initWithFrame:CGRectMake(0, ScreenHeight-Botoom_IPhoneX-FIT(60), ScreenWidth, FIT(50))];
        _footView.backgroundColor = WhiteColor;
        [_footView.collectionBtn setTitle:@"创建钱包" forState:UIControlStateNormal];
        [_footView.transferBtn setTitle:@"导入钱包" forState:UIControlStateNormal];
        @weakify(self);
        _footView.SelectBlock = ^(NSInteger index) {
            @strongify(self);
            //创建钱包
            if (index == 1) {
                YQ_PUSH([YQNewWalletAddressVC new]);
            }else {
                YQ_PUSH([YQImportWalletVC new]);
            }
            
        };
    }
    return _footView;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return FIT(105);
}

//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
//    return FIT(10);
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
//    return 0.0001;
//}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQManagerCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_ManagerCell forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    YQ_PUSH([YQWalletDetailVC new]);
}

@end
